package org.glandais.games.rebondrobots.board;

public class Cell {

	private int x;
	private int y;

	private Border[] borders = new Border[4];

	private Goal goal;

	public Cell(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}

	private void setBorder(Border border, Direction direction) {
		borders[direction.ordinal()] = border;
	}

	public Border getBorder(Direction direction) {
		return borders[direction.ordinal()];
	}

	public Border getNorth() {
		return getBorder(Direction.NORTH);
	}

	public void setNorth(Border border) {
		setBorder(border, Direction.NORTH);
	}

	public Border getEast() {
		return getBorder(Direction.EAST);
	}

	public void setEast(Border border) {
		setBorder(border, Direction.EAST);
	}

	public Border getSouth() {
		return getBorder(Direction.SOUTH);
	}

	public void setSouth(Border border) {
		setBorder(border, Direction.SOUTH);
	}

	public Border getWest() {
		return getBorder(Direction.WEST);
	}

	public void setWest(Border border) {
		setBorder(border, Direction.WEST);
	}

	public Goal getGoal() {
		return goal;
	}

	public void setGoal(Goal goal) {
		this.goal = goal;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Cell other = (Cell) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		return true;
	}

}
